<?php
namespace App\Services;

use Illuminate\Support\Facades\Redis;

class KafkaBridgeService
{
    const KEY = 'KafkaBridge';

    public function getKey()
    {
        return self::KEY;
    }

    public function push($event) {
        $body = [
            'tag' => $event->getTag(),
            'body' => json_encode($event)
        ];
        $bodyMessage = json_encode($body);

        if (app()->environment('production') || app()->environment('integration')) {
            $redis = Redis::connection();
            $redis->lpush(self::KEY, $bodyMessage);
        }
    }
}